#include <iostream>
#include <cstring>

using namespace std;
const int N = 100010;
int n;
int a[N];

void ShellSort(int a[] , int n)
{
  int gap = n;

  //当gap为1的时候是 预排序
  //当gap大于1的时候是 直接插入排序
  
  while (gap > 1)
  {
    gap = gap / 5 + 1;
    for (int i = 0 ; i < n - gap ; i ++)
    {
      int end = i;
      int temp = a[end + gap];
      while (end >= 0)
      {
        if (temp < a[end])
        {//此时需要进行交换
          a[end + gap] = a[end];
          end -= gap;
        }

        else break;
      }
      a[end + gap] = temp;
    }
  }
}

int main()
{
  cin >> n;
  for (int i = 0 ; i < n ; i ++)
  {
    cin >> a[i];
  }

  ShellSort(a , n);

  for (int i = 0 ; i < n ; i ++)
  {
    cout << a[i] << ' ';
  }
  cout << endl;

  return 0;

}
